import { createSlice } from "@reduxjs/toolkit";
import { SessionStorageManager } from "../../cache";
const sessionStorageManager = new SessionStorageManager()



export const useSlice = createSlice({
  name: "user",
  initialState:sessionStorageManager.getItem('redux-user') || {
    histroys: []
  },
  reducers: {
    setHistorys(state, action): any {
      /**
       * 判断当前面包屑是否存在，不存在则push进去
       * 存在把他放到数组最后面
       */
      return {
        ...state,
        histroys: action.payload || [],
      };
    },
  },
});

export const { setHistorys } = useSlice.actions;
